<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2005 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* changed by Piero Trono (c) 2005 for http://php-multishop.com         */
/************************************************************************/
/* $Id: index.php,v 1.1.1.1 2005/11/21 13:48:11 tropic Exp $ */

if (!defined('MODULE_FILE')) {
	die ("You can't access this file directly...");
}

define('INDEX_FILE', true);
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);

#== // MultiShop
$name_language = "name_" . $currentlang;
$name_default = "name_" . DEFAULT_LANGUAGE;
$language_id = $lang_id[$currentlang];
if (!isset($language_id)){
	$language_id = 1;
}
function show_all_vendors(){
    global $prefix, $db, $Conf_Multishop, $user, $usession;
    $result = $db->sql_query("SELECT * FROM ".$prefix."_vendors WHERE vendors_type != 'inactive' ORDER BY vendors_name");
    
    OpenTable();
    if ($db->sql_numrows($result)){
	echo  "<center><font class=\"title\"><b>" . _SHOPS_ONLINE . "</b></font></center>";
    echo "<br><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" align=\"center\">";
	
	if (is_user($user) && isset($usession)){
	    while ($row = $db->sql_fetchrow($result)) {
	    	
	    	$Row = $db->sql_fetchrow($db->sql_query("SELECT logo FROM ".$prefix."_vendors_details WHERE vendors_id=$row[vendors_id]"));
	    	$logo = $Row['logo'];
	    	echo "<tr><td>&nbsp;&nbsp;</td><td><br><br></td><td><br><br></td></tr><tr><td>&nbsp;&nbsp;</td><td align=\"left\">&nbsp;&nbsp;";
	    	if ($logo) echo "<img src=\"images/vendors/$logo\" border=\"0\" width=\"$Conf_Multishop[widht_logo]\" alt=\"$row[vendors_name]\">";
	    	echo "&nbsp;&nbsp;</td><td align=\"left\">";
	    	echo "&nbsp;&nbsp;<font class=\"title\"><b>$row[vendors_name]</b></font><br><br>";
	    	echo "&nbsp;&nbsp;<a href=\"modules.php?name=Multishop&amp;op=detail_vendor&amp;vendors_id=$row[vendors_id]\" title=\"" . _DETAILS_VENDOR . "\"><b>" . _DETAILS_VENDOR . "</b></a><br><br>\n";
	    	if ($row['vendors_type'] != "external") {
	    		$row['vendors_host'] = ereg_replace("index.php","login.php",$row[vendors_host]);
	    		echo "&nbsp;&nbsp;<a href=\"http://$row[vendors_host]?usession=$usession\"";
	    	} else {
	    		echo "&nbsp;&nbsp;<a href=\"http://$row[vendors_host]\"";
	    	}
	    	echo " title=\"" . _GO_TO_SHOP . "\" target=\"_blank\"><b>" . _GO_TO_SHOP . "</b></a>";
	    	echo "&nbsp;&nbsp;<br><br></td></tr>";
	    }
	} else {
	    while ($row = $db->sql_fetchrow($result)) {
	    	
	    	$Row = $db->sql_fetchrow($db->sql_query("SELECT logo FROM ".$prefix."_vendors_details WHERE vendors_id=$row[vendors_id]"));
	    	$logo = $Row['logo'];
	    	echo "<tr><td>&nbsp;&nbsp;</td><td><br><br></td><td><br><br></td></tr><tr><td>&nbsp;&nbsp;</td><td align=\"left\">&nbsp;&nbsp;";
	    	if ($logo) echo "<img src=\"images/vendors/$logo\" border=\"0\" width=\"$Conf_Multishop[widht_logo]\" alt=\"$row[vendors_name]\">";
	    	echo "&nbsp;&nbsp;</td><td align=\"left\">";
	    	echo "&nbsp;&nbsp;<font class=\"title\"><b>$row[vendors_name]</b></font><br><br>";
	    	echo "&nbsp;&nbsp;<a href=\"modules.php?name=Multishop&amp;op=detail_vendor&amp;vendors_id=$row[vendors_id]\" title=\"" . _DETAILS_VENDOR . "\"><b>" . _DETAILS_VENDOR . "</b></a><br><br>\n";
	    	echo "&nbsp;&nbsp;<a href=\"http://$row[vendors_host]\" title=\"" . _GO_TO_SHOP . "\"><b>" . _GO_TO_SHOP . "</b></a>";
	    	echo "&nbsp;&nbsp;<br><br></td></tr>";
	    }
	}
	
	echo "</table>";

    } else {
	echo  "<center><font class=\"title\"><b>" . _SHOPS_NOT_FOUND . "</b></font></center>";
    }
    CloseTable();
}

function show_prods(){
    global $currentcurrency, $currencies, $language_id, $prefix, $Conf_Multishop, $cookie, $currentlang, $multilingual, $db, $module_name, $name_language, $name_default, $user, $usession;
    
    $max_prod = $Conf_Multishop['num_prod_home'];
    $num_line = $Conf_Multishop['num_prod_line'];
    $num_total = $Conf_Multishop['home_prods'];
    $included_tax = $Conf_Multishop['include_taxrate'];
    $show_tax = $Conf_Multishop['show_taxrate']; 
    $prods = array();
    $result = $db->sql_query("SELECT * FROM ".$prefix."_vendors where show_prods='1'");
    $num_vend = $db->sql_numrows($result);
    $i = 1 ;
    $decimal_places = $currencies->get_decimal_places($currentcurrency);
    while ($row = $db->sql_fetchrow($result)) {
    		
    	$pos = strrpos($row['vendors_host'], '/');
    	$host = substr($row['vendors_host'], 0, $pos) . "/";
    	if ($row['vendors_type'] == "external") $external = 1; else $external = 0;

    	$Res = $db->sql_query("select p.products_id, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . $row['vendors_prefix'] . "_" . TABLE_PRODUCTS . " p, " . $row['vendors_prefix'] . "_" . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . $row['vendors_prefix'] . "_" . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and p.products_id = pd.products_id and (pd.language_id = '" . $language_id . "' ) ORDER BY RAND() LIMIT 0,$max_prod");
    	
    	while ($Row = $db->sql_fetchrow($Res)) {

    		array_push($prods,$i);
        	$tax_result = $db->sql_fetchrow($db->sql_query("select tax_rate from " . $row['vendors_prefix'] . "_tax_rates where tax_class_id = '" . $Row['products_tax_class_id'] . "'"));
			$tax = $tax_result['tax_rate'];
			$prod_tax[$i] = tep_round($tax, $decimal_places);
    		$host_prods[$i] = $host;
    		$vend_external[$i] = $external;
    		$prod_id[$i] = $Row['products_id'];
    		$prod_image[$i] = $Row['products_image'];
    		$prod_name[$i] = $Row['products_name'];
    		$price = $Row['final_price'];

    		if ($included_tax == 1 && intval($tax)){
    			$new_price = $price * ($tax / 100 +1);
    			$new_price = tep_round($new_price, $decimal_places);
    			$prod_price[$i] = $currencies->format($new_price);
    		} else {
    			$prod_price[$i] = $currencies->format($price);
    		}
    		
    		$i ++;
    	}
    }
    
    OpenTable();
    echo  "<center><font class=\"title\"><b>" . _SOME_PRODUCTS . "</b></font></center>";
    echo '<table border="0" width="100%" cellspacing="0" cellpadding="0">' . "\n\n";
    
    $n =1;
    shuffle($prods);
    $prods = array_slice($prods, 0, $num_total);

    if ($num_vend == 0 ) {
	echo "<center><br><font class=\"content\">"._SHOPS_NOT_FOUND."<br><br></font>";
    } elseif (empty($prods)){
	echo "<center><br><font class=\"content\">"._PRODUCTS_NOT_FOUND."<br><br></font>";
    } elseif (is_user($user) && isset($usession)){
    	foreach($prods as $i){
    	    if ($n == 1 || ($n % $num_line) == 1) echo '<tr>';
    	    echo "\n<td>";
    	    if ($vend_external[$i] == 1){
    	    	$my_url = "product_info.php?";
    	    } else {
    	    	$my_url = "login.php?usession=$usession&redirect=product_info.php&amp;";
    	    }
    	    echo "<center><br><a href=\"http://". $host_prods[$i] . $my_url . "products_id=" . $prod_id[$i] . "\" title=\"" . _DETAILS_PROD . "\" target=\"_blank\">";
    	    echo "<img src=\"http://" . $host_prods[$i] . "images/" . $prod_image[$i] ."\" width=\"100\" border=\"0\" alt=\"" . _DETAILS_PROD . "\"></a>";
    	    echo "<br><a href=\"http://". $host_prods[$i] . $my_url . "products_id=" . $prod_id[$i] . "\" title=\"" . _DETAILS_PROD . "\" target=\"_blank\"><b>$prod_name[$i]</b></a>\n";
    	    echo "<br>$prod_price[$i]";
    	    
    	    // show tax_rate
    	    if ($show_tax == 1 && intval($prod_tax[$i])){
    	    	echo "<br>(tax: $prod_tax[$i]%)";
    	    }
    	    
    	    echo "</center>";
    	    echo "</td>\n";
    	    if ( $n == count($prods) || ($n % $num_line) == 0) echo '</tr>';
    	    $n ++;
    	}
    } else {
    	foreach($prods as $i){
    	    if ($n == 1 || ($n % $num_line) == 1) echo '<tr>';
    	    echo "\n<td>";
    	    echo "<center><br><a href=\"http://". $host_prods[$i] . "product_info.php?products_id=" . $prod_id[$i] . "\" title=\"" . _DETAILS_PROD . "\" target=\"_blank\">";
    	    echo "<img src=\"http://" . $host_prods[$i] . "images/" . $prod_image[$i] ."\" width=\"100\" border=\"0\" alt=\"" . _DETAILS_PROD . "\"></a>\n";
    	    echo "<br><a href=\"http://". $host_prods[$i] . "product_info.php?products_id=" . $prod_id[$i] . "\" title=\"" . _DETAILS_PROD . "\" target=\"_blank\"><b>$prod_name[$i]</b></a>";
    	    echo "<br>$prod_price[$i]";
    	    
    	    // show tax_rate
    	    if ($show_tax == 1 && intval($prod_tax[$i])){
    	    	echo "<br>(tax: $prod_tax[$i]%)";
    	    }
    	    echo "</center>";
    	    echo "</td>\n";
    	    if ( $n == count($prods) || ($n % $num_line) == 0) echo '</tr>';
    	    $n ++;
    	}
    }
    echo '</table>';
    CloseTable();
}
#== //

function theindex($new_topic="0") {
   	global $Conf_Multishop, $usession, $db, $storyhome, $topicname, $topicimage, $topictext, $datetime, $user, $cookie, $nukeurl, $prefix, $multilingual, $currentlang, $articlecomm, $sitename, $user_news, $userinfo;
   	if (is_user($user)) { getusrinfo($user); }
	if ($multilingual == 1) {
		$querylang = "AND (alanguage='$currentlang' OR alanguage='')";
	} else {
		$querylang = "";
	}
    include("header.php");
    automated_news();
    if (isset($new_topic)) {
            $new_topic = intval($new_topic);
    } else {
            $new_topic == 0;
    }

#== // MultiShop
    $num_total = intval($Conf_Multishop['home_prods']);
    $ms_num_news = intval($Conf_Multishop['home_news']);

    if (isset($userinfo['setstorynum']) AND $user_news == 1) {
		$storynum = $userinfo['setstorynum'];
    } elseif ($ms_num_news > 0) {
    	$storynum = $ms_num_news;
#== //
	} else {
		$storynum = $storyhome;
	}
	if ($new_topic == 0) {
		$qdb = "WHERE (ihome='0' OR catid='0')";
		$home_msg = "";
	} else {
		$qdb = "WHERE topic='$new_topic'";
		$result_a = $db->sql_query("SELECT topictext FROM ".$prefix."_topics WHERE topicid='$new_topic'");
		$row_a = $db->sql_fetchrow($result_a);
		$numrows_a = $db->sql_numrows($result_a);
		$topic_title = stripslashes(check_html($row_a['topictext'], "nohtml"));
		OpenTable();
		if ($numrows_a == 0) {
			echo "<center><font class=\"title\">$sitename</font><br><br>"._NOINFO4TOPIC."<br><br>[ <a href=\"modules.php?name=News\">"._GOTONEWSINDEX."</a> | <a href=\"modules.php?name=Topics\">"._SELECTNEWTOPIC."</a> ]</center>";
		} else {
			$db->sql_query("UPDATE ".$prefix."_topics SET counter=counter+1");
			echo "<center><font class=\"title\">$sitename: $topic_title</font><br><br>"
			."<form action=\"modules.php?name=Search\" method=\"post\">"
			."<input type=\"hidden\" name=\"topic\" value=\"$new_topic\">"
			.""._SEARCHONTOPIC.": <input type=\"name\" name=\"query\" size=\"30\">&nbsp;&nbsp;"
			."<input type=\"submit\" value=\""._SEARCH."\">"
			."</form>"
			."[ <a href=\"index.php\">"._GOTOHOME."</a> | <a href=\"modules.php?name=Topics\">"._SELECTNEWTOPIC."</a> ]</center>";
		}
		CloseTable();
		echo "<br>";
	}
	$result = $db->sql_query("SELECT sid, catid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes, acomm, score, ratings FROM ".$prefix."_stories $qdb $querylang ORDER BY sid DESC limit $storynum");
	while ($row = $db->sql_fetchrow($result)) {
		$s_sid = intval($row['sid']);
		$catid = intval($row['catid']);
		$aid = stripslashes($row['aid']);
		$title = stripslashes(check_html($row['title'], "nohtml"));
		$time = $row['time'];
		$hometext = stripslashes($row['hometext']);
		$bodytext = stripslashes($row['bodytext']);
		$comments = stripslashes($row['comments']);
		$counter = intval($row['counter']);
		$topic = intval($row['topic']);
		$informant = stripslashes($row['informant']);
		$notes = stripslashes($row['notes']);
		$acomm = intval($row['acomm']);
		$score = intval($row['score']);
		$ratings = intval($row['ratings']);
		if ($catid > 0) {
			$row2 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories_cat WHERE catid='$catid'"));
			$cattitle = stripslashes(check_html($row2['title'], "nohtml"));
		}
		getTopics($s_sid);
		formatTimestamp($time);
		$introcount = strlen($hometext);
		$fullcount = strlen($bodytext);
		$totalcount = $introcount + $fullcount;
		$c_count = $comments;
		$r_options = "";
		if (isset($userinfo['umode'])) { $r_options .= "&amp;mode=".$userinfo['umode']; }
		if (isset($userinfo['uorder'])) { $r_options .= "&amp;order=".$userinfo['uorder']; }
		if (isset($userinfo['thold'])) { $r_options .= "&amp;thold=".$userinfo['thold']; }
		$story_link = "<a href=\"modules.php?name=News&amp;file=article&amp;sid=$s_sid$r_options\">";
		$morelink = "(";
		if ($fullcount > 0 OR $c_count > 0 OR $articlecomm == 0 OR $acomm == 1) {
			$morelink .= "$story_link<b>"._READMORE."</b></a> | ";
		} else {
			$morelink .= "";
		}
		if ($fullcount > 0) { $morelink .= "$totalcount "._BYTESMORE." | "; }
		if ($articlecomm == 1 AND $acomm == 0) {
			if ($c_count == 0) { $morelink .= "$story_link"._COMMENTSQ."</a>"; } elseif ($c_count == 1) { $morelink .= "$story_link$c_count "._COMMENT."</a>"; } elseif ($c_count > 1) { $morelink .= "$story_link$c_count "._COMMENTS."</a>"; }
		}
		$sid = intval($s_sid);
		if ($catid != 0) {
			$row3 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories_cat WHERE catid='$catid'"));
			$title1 = stripslashes(check_html($row3['title'], "nohtml"));
			$title = "<a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid=$catid\"><font class=\"storycat\">$title1</font></a>: $title";
			$morelink .= " | <a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid=$catid\">$title1</a>";
		}
		if ($score != 0) {
			$rated = substr($score / $ratings, 0, 4);
		} else {
			$rated = 0;
		}
		$morelink .= " | "._SCORE." $rated";
		$morelink .= ")";
		$morelink = str_replace(" |  | ", " | ", $morelink);
		themeindex($aid, $informant, $datetime, $title, $counter, $topic, $hometext, $notes, $morelink, $topicname, $topicimage, $topictext);
	}

#== // MultiShop
    if ($ms_num_news < $storyhome) echo "<center><a href=\"modules.php?name=News&amp;file=index_news\"><b>" . _READ_MORE_NEWS . "</b></a></center><br>";
    if (intval($Conf_Multishop['show_shops']) == 1 ) {
    	show_all_vendors();
    	echo "<br>";
    }
    if ($num_total > 0 ) {
    	show_prods();
    }
#== //

	include("footer.php");
}

function rate_article($sid, $score, $random_num="0", $gfx_check) {
	global $prefix, $db, $ratecookie, $sitename, $r_options, $sitekey, $gfx_chk, $module_name;
	if (isset($random_num)) {
		$datekey = date("F j");
		$rcode = hexdec(md5($_SERVER['HTTP_USER_AGENT'] . $sitekey . $random_num . $datekey));
		$code = substr($rcode, 2, 3);
		if (extension_loaded("gd") AND $code != $gfx_check AND $gfx_chk != 0) {
			mt_srand ((double)microtime()*1000000);
			$maxran = 1000000;
			$random_num = mt_rand(0, $maxran);
			include("header.php");
			title("$sitename: "._ARTICLERATING."");
			OpenTable();
			$row = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories WHERE sid='$sid'"));
			echo "<center><a href=\"modules.php?name=$module_name&file=article&sid=$sid$r_options\"><b>".$row['title']."</b></a><br>"._ARTICLERATING.": <img src=\"images/articles/stars-$score.gif\" border=\"0\" alt=\"$score/5\" title=\"$score/5\"> ($score/5)<br><br>";
			echo ""._TOFINISHRATINGERROR."<br><br>";
			echo "<form action=\"modules.php?name=$module_name\" method=\"post\">";
			echo ""._SECURITYCODE.":<br><img src='?gfx=gfx_little&random_num=$random_num' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'><br><br>\n";
			echo ""._TYPESECCODE.":<br><input type=\"text\" NAME=\"gfx_check\" SIZE=\"3\" MAXLENGTH=\"3\"><br>\n";
			echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num\"><br>\n";
			echo "<input type=\"hidden\" name=\"score\" value=\"$score\"><br>\n";
			echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\">\n";
			echo "<input type=\"hidden\" name=\"op\" value=\"rate_article\">";
			echo "<input type=\"submit\" value=\""._CASTMYVOTE."\"></font></center></form>";
			CloseTable();
			include("footer.php");
			die();
		} else {
			$score = intval($score);
			$sid = intval($sid);
			if ($score) {
				if ($score > 5) { $score = 5; }
				if ($score < 1) { $score = 1; }
				if ($score != 1 AND $score != 2 AND $score != 3 AND $score != 4 AND $score != 5) {
					Header("Location: index.php");
					die();
				}
				$ip = $_SERVER['REMOTE_ADDR'];
				$num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_stories WHERE sid='$sid' AND rating_ip='$ip'"));
				if ($num != 0) {
					Header("Location: modules.php?name=News&op=rate_complete&sid=$sid&rated=1");
					die();
				}
				if (isset($ratecookie)) {
					$rcookie = base64_decode($ratecookie);
					$rcookie = addslashes($rcookie);
					$r_cookie = explode(":", $rcookie);
				}
				for ($i=0; $i < sizeof($r_cookie); $i++) {
					if ($r_cookie[$i] == $sid) {
						$a = 1;
					}
				}
				if ($a == 1) {
					Header("Location: modules.php?name=News&op=rate_complete&sid=$sid&rated=1");
					die();
				} else {
					$ip = $_SERVER['REMOTE_ADDR'];
					$result = $db->sql_query("update ".$prefix."_stories set score=score+$score, ratings=ratings+1, rating_ip='$ip' where sid='$sid'");
					$info = base64_encode("$rcookie$sid:");
					setcookie("ratecookie","$info",time()+86400);
					update_points(7);
					Header("Location: modules.php?name=News&op=rate_complete&sid=$sid&score=$score");
				}
			} else {
				include("header.php");
				title("$sitename: "._ARTICLERATING."");
				OpenTable();
				echo "<center>"._DIDNTRATE."<br><br>"
				.""._GOBACK."</center>";
				CloseTable();
				include("footer.php");
			}
		}
	} else {
		mt_srand ((double)microtime()*1000000);
		$maxran = 1000000;
		$random_num = mt_rand(0, $maxran);
		if (extension_loaded("gd") AND $gfx_chk != 0 ) {
			include("header.php");
			title("$sitename: "._ARTICLERATING."");
			OpenTable();
			$row = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories WHERE sid='$sid'"));
			echo "<center><a href=\"modules.php?name=$module_name&file=article&sid=$sid$r_options\"><b>".$row['title']."</b></a><br>"._ARTICLERATING.": <img src=\"images/articles/stars-$score.gif\" border=\"0\" alt=\"$score/5\" title=\"$score/5\"> ($score/5)<br><br>";
			echo ""._TOFINISHRATING."<br><br>";
			echo "<form action=\"modules.php?name=$module_name\" method=\"post\">";
			echo ""._SECURITYCODE.":<br><img src='?gfx=gfx_little&random_num=$random_num' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'><br><br>\n";
			echo ""._TYPESECCODE.":<br><input type=\"text\" NAME=\"gfx_check\" SIZE=\"3\" MAXLENGTH=\"3\"><br>\n";
			echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num\"><br>\n";
			echo "<input type=\"hidden\" name=\"score\" value=\"$score\"><br>\n";
			echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\">\n";
			echo "<input type=\"hidden\" name=\"op\" value=\"rate_article\">";
			echo "<input type=\"submit\" value=\""._CASTMYVOTE."\"></font></center></form>";
			CloseTable();
			include("footer.php");
		} else {
			$random_num = "$random_num";
			$gfx_check = "$code";
			Header("Location: modules.php?name=$module_name&op=rate_article&sid=$sid&score=$score&random_num=$random_num");
		}
	}
}

function rate_complete($sid, $rated=0, $score) {
	global $sitename, $user, $cookie, $module_name, $userinfo;
	$r_options = "";
	if (is_user($user)) {
                getusrinfo($user);
		if (isset($userinfo['umode'])) { $r_options .= "&amp;mode=".$userinfo['umode']; }
		if (isset($userinfo['uorder'])) { $r_options .= "&amp;order=".$userinfo['uorder']; }
		if (isset($userinfo['thold'])) { $r_options .= "&amp;thold=".$userinfo['thold']; }
	}
	include("header.php");
	title("$sitename: "._ARTICLERATING."");
	OpenTable();
	if ($rated == 0) {
		$row = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories WHERE sid='$sid'"));
		echo "<center><a href=\"modules.php?name=$module_name&file=article&sid=$sid$r_options\"><b>".$row['title']."</b></a><br>"._YOURATEDARTICLE.": <img src=\"images/articles/stars-$score.gif\" border=\"0\" alt=\"$score/5\" title=\"$score/5\"> ($score/5)<br><br>";
		echo "<center>"._THANKSVOTEARTICLE."<br><br>"
		."[ <a href=\"modules.php?name=$module_name&amp;file=article&amp;sid=$sid$r_options\">"._BACKTOARTICLEPAGE."</a> ]</center>";
	} elseif ($rated == 1) {
		echo "<center>"._ALREADYVOTEDARTICLE."<br><br>"
		."[ <a href=\"modules.php?name=$module_name&amp;file=article&amp;sid=$sid$r_options\">"._BACKTOARTICLEPAGE."</a> ]</center>";
	}
	CloseTable();
	include("footer.php");
}

if (!(isset($new_topic))) { $new_topic = 0; }
if (!(isset($op))) { $op = ""; }

switch ($op) {

	case "rate_article":
	rate_article($sid, $score, $random_num, $gfx_check);
	break;

	case "rate_complete":
	rate_complete($sid, $rated, $score);
	break;

	default:
	theindex($new_topic);
	break;
}

?>